 module mem_tuv
   USE ModTuv, ONLY: nw

  implicit none
  
  type mtuv
  REAL,ALLOCATABLE,DIMENSION(:,:,:,:) :: g_tauaer
  REAL,ALLOCATABLE,DIMENSION(:,:,:,:) :: g_wol
  REAL,ALLOCATABLE,DIMENSION(:,:,:,:) :: g_gol
  REAL,ALLOCATABLE,DIMENSION(:,:,:,:) :: g_taucld 
  REAL,ALLOCATABLE,DIMENSION(:,:,:,:) :: g_wcld
  REAL,ALLOCATABLE,DIMENSION(:,:,:,:) :: g_gcld
  end type
  
  type (mtuv), allocatable, dimension(:) :: carma_tuv
  
  INTEGER,DIMENSION(:),allocatable :: tuv2carma  

 contains

  subroutine alloc_carma_tuv()
    use mem_globrad, only : ntotal, nlayer
    use mem_grid, only : ngrids,nnxp,nnyp
    integer i

    allocate (carma_tuv(ngrids))
    
    do i=1,ngrids
   ! print*,'XX=',ntotal,nlayer,nnxp(i),nnyp(i); call flush(6)
    
     allocate (carma_tuv(i)%g_tauaer(ntotal,nlayer,nnxp(i),nnyp(i)))    
     allocate (carma_tuv(i)%g_wol   (ntotal,nlayer,nnxp(i),nnyp(i)))
     allocate (carma_tuv(i)%g_gol   (ntotal,nlayer,nnxp(i),nnyp(i)))
     allocate (carma_tuv(i)%g_taucld(ntotal,nlayer,nnxp(i),nnyp(i)))
     allocate (carma_tuv(i)%g_wcld  (ntotal,nlayer,nnxp(i),nnyp(i)))
     allocate (carma_tuv(i)%g_gcld  (ntotal,nlayer,nnxp(i),nnyp(i)))
    enddo  
 
    allocate(tuv2carma(nw))
    
    return
  end subroutine alloc_carma_tuv
end module mem_tuv
